﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;

namespace HYLightingEquipmentLay
{
	internal class DeleteWarning
	{
		public static void OnFailuresProcessing(object sender, FailuresProcessingEventArgs e)
		{
			DeleteWarning.DeleteWarnings("Topology", e);
			DeleteWarning.DeleteWarnings("primary", e);
			DeleteWarning.DeleteWarnings("new wall", e);
			DeleteWarning.DeleteWarnings("CreateFamilyInstance", e);
			DeleteWarning.DeleteWarnings("layout", e);
			DeleteWarning.DeleteWarnings("CreateSketchPl", e);
			DeleteWarning.DeleteWarnings("CreateFilledRegion", e);
			DeleteWarning.DeleteWarnings("TransactionGroup", e);
			DeleteWarning.DeleteWarnings("modify wall attribute", e);
		}

		public static void DeleteWarnings(string strTrans, FailuresProcessingEventArgs e)
		{
			FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
			string transactionName = failuresAccessor.GetTransactionName();
			IList<FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();
			if (failureMessages.Count == 0)
			{
				e.SetProcessingResult((FailureProcessingResult)0);
				return;
			}
			if (transactionName.Equals(strTrans))
			{
				foreach (FailureMessageAccessor failureMessageAccessor in failureMessages)
				{
					failuresAccessor.DeleteWarning(failureMessageAccessor);
				}
				e.SetProcessingResult((FailureProcessingResult)1);
				return;
			}
			e.SetProcessingResult((FailureProcessingResult)0);
		}
	}
}
